package com.doit.spark.practise

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @DATE 2022/1/8/21:41
 * @Author MDK
 * @Version 2021.2.2
 * */
object C01_CreateRDD {
  def main(args: Array[String]): Unit = {
    //创建Spark环境
    val conf = new SparkConf()
    conf.setAppName("demo").setMaster("local[*]")
    val sc = new SparkContext(conf)

    //调用函数 创建本地的RDD
    val rdd1: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4, 5))
    val rdd2: RDD[String] = sc.parallelize(Seq[String]("java", "sql", "scala", "hbase"))
    rdd1.collect().foreach(println)
//    sc.stop()


    //查看分区信息
    println(rdd2.toDebugString)
    //线程等待  访问网页4040
    Thread.sleep(Int.MaxValue)
  }
}
